/*
 * 战争机器
 */
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using SimpleJson;

namespace Dolls
{
    /// <summary>
    /// 战争机器数据
    /// </summary>
    public class cMachineData
    {
        public cMachineResData res;
    }

    /// <summary>
    /// 战争机器资源类型
    /// </summary>
    public class cMachineResData
    {
        public int Id;
        public string name;
        public string nameE;
        public string des;
        public string desE;
        public eMachineType type;
        public float atk;
        public float def;
        public float EDef;
        public float dodge;
        public eBullet bulletType;
        public string iconPath;
        public string modlePath;

    }

    /// <summary>
    /// 战争资源数据
    /// </summary>
    public class CMachineManager : cDataBase<cMachineResData, CMachineManager>
    {
        protected override string GetPath()
        {
            return "Assets/project/res/warDolls.json";
        }

        protected override void ReadData(JsonArray array)
        {
            foreach (JsonObject item in array)
            {
                cMachineResData info = new()
                {
                    Id = Convert.ToInt32(item["index"]),
                    name = Convert.ToString(item["name"]),
                    nameE = Convert.ToString(item["nameE"]),
                    des = Convert.ToString(item["des"]),
                    desE = Convert.ToString(item["desE"]),
                    type = Enum.Parse< eMachineType >( Convert.ToString(item["type"])),

                    atk = Convert.ToSingle(item["Atk"]),
                    def = Convert.ToSingle(item["Def"]),
                    EDef = Convert.ToSingle(item["EDef"]),
                    dodge = Convert.ToSingle(item["Dodge"]),
                    bulletType = Enum.Parse<eBullet> (Convert.ToString(item["bullet"])),

                    iconPath = Convert.ToString(item["icon"]),
                    modlePath = Convert.ToString(item["modleAssetIndex"]),

                };
                mDict.Add(info.Id, info);
            }
            gameUtility.Log("read machines.json ok");
        }


    }
    

}


